package main.java.ensao.cryptography.elgamalmodule;

import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class ElGAMALDecryptionListner  implements ActionListener {
	
	public void actionPerformed(ActionEvent e) {

		
		JPanel pan = (JPanel) ((JButton) e.getSource()).getParent();
		pan.setForeground(new Color(255, 255, 10));
		
		JTextField p = (JTextField) (((JPanel) pan.getComponent(1))).getComponent(1);
	    JTextField b = (JTextField) (((JPanel) pan.getComponent(5))).getComponent(1);
        JTextField clair = (JTextField) (((JPanel) pan.getComponent(11))).getComponent(1);
	    JTextField chiffré = (JTextField) (((JPanel) pan.getComponent(12))).getComponent(1);
	    JTextField Kalpha = (JTextField) (((JPanel) pan.getComponent(13))).getComponent(1);

	    ElGamal gamal=new ElGamal();
	    gamal.Decryption(chiffré.getText(),  p.getText(), Kalpha.getText(),b.getText());

	    clair.setText(gamal.getM().toString());
		

	}

}
